<?php
	$school = $_SESSION['school'];
	$_SESSION['facultyid'] = $faculty->getId();
//	$faculty = $_REQUEST['faculty'];
//	$notices = $_REQUEST['notices'];
//	$departments = $_REQUEST['departments'];
?>
<script type="text/javascript" src="js/faculty.js"></script>
<input type="hidden" id="schoolid" name="schoolid" value="<?php echo $school->getId(); ?>">
<input type="hidden" id="facultyid" name="facultyid" value="<?php echo $faculty->getId(); ?>">
<div class="ui-corner-all"><?php include "view/topmenu.php"; ?></div>
<div class="block">
	Welcome <?php 
		if(!empty($_SESSION['user'])){
			$user = $_SESSION['user'];
			echo $user->getName();
		}
	?> :
	<a href="javascript:void(0)" id="linkHome">Home</a> &gt;
	<b>Faculty</b>
</div>
<div class="block">
	<!-- Description -->
	<fieldset>
		<legend id="facultyname"><?php echo $faculty->getName(); ?></legend>
		<span id="spnFacultyDesc" name="spnFacultyDesc"><?php echo $faculty->getDescription(); ?></span>
		<?php HTMLUtil::EditButton("editFacultyDesc");  ?>
		<br/><br/>
		<small><b>Dean : </b> <span id="spnChairperson"><?php echo $faculty->getPicname(); ?></span></small> <?php HTMLUtil::EditButton("editFacultyPic");  ?>
	</fieldset>
	<!-- Notice -->
	<fieldset>
		<legend>Notice</legend>
		<div id="noticelist">
			<?php
				foreach($notices as $notice){
					echo "<span id=\"spnnotice" . $notice->getId() ."\">";
					echo "<b>" . $notice->getSubject() . "</b><br/><span>";
					echo $notice->getContent() . "</span> ";
					HTMLUtil::WriteActionButton("Edit", "editNotice('" . $notice->getId() . "')");
					echo " ";
					HTMLUtil::WriteActionButton("Delete", "deleteNotice('" . $notice->getId() . "')");
					echo "<hr></span>\n";
				}
			?>
		</div>
		<div class="block">
			<?php HTMLUtil::AddButton("addFacultyNotice"); ?>
		</div>
	</fieldset>
	<!-- Departments -->
	<fieldset>
		<legend>Departments</legend>
		<ul id="departmentlist">
			<?php
				foreach($departments as $department){
					echo "<li id=\"lidepartment" . $department->getId() . "\">";
					echo $department->getName() . " ";
					HTMLUtil::WriteActionButton("View", "viewDepartment('" . $department->getId() . "')");
					echo " ";
					HTMLUtil::WriteActionButton("Delete", "deleteDepartment('" . $department->getId() . "')");
					echo "</li>\n";
				}
			?>
		</ul>	
		<div class="block">
			<?php HTMLUtil::AddButton("addDepartment"); ?>
		</div>
	</fieldset>
	
	<!-------------------------------------- Diaologs ---------------------------------->
	<div id="dialog_faculty_desc" title="School Description">
		<label for="newfacultyname">Name</label>
		<input type="text" id="newfacultyname" class="text ui-widget-content ui-corner-all"/>
		<textarea id="facultydesc" name="facultydesc" cols="50" rows="8" class="text ui-widget ui-corner-all"></textarea>
	</div>
	
	<div id="dialog_faculty_pic" title="Dean">
		<select id="selChairperson"></select>
	</div>
	
	<div id="dialog_newnotice" title="New Notice">
		<form>
			<fieldset>
				<label for="new_notice_subject">Subject</label>
				<input type="text" id="new_notice_subject" class="text ui-widget-content ui-corner-all"/>
				<textarea id="new_notice_content" cols="50" rows="8"></textarea>
			</fieldset>
		</form>
	</div>
	<div id="dialog_editnotice" title="Edit Notice">
		<form>
			<fieldset>
				<label for="edit_notice_subject">Subject</label>
				<input type="text" id="edit_notice_subject" class="text ui-widget-content ui-corner-all"/>
				<textarea id="edit_notice_content" cols="50" rows="8"></textarea>
				<input type="hidden" id="edit_notice_id" />
			</fieldset>
		</form>
	</div>
	<div id="dialog_new_department" title="New Department">
		<fieldset>
			<label for="department_name">Name</label>
			<input type="text" id="department_name"/><br>
			<label for="dean">Dean</label>
			<select id="dean"></select>
			<textarea id="department_description" cols="50" rows="8"></textarea>
		</fieldset>
	</div>

</div>
